package com.hpjpw.ido.controller;

import java.util.List;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hpjpw.ido.domain.TaskRecord;
import com.hpjpw.ido.service.ITaskRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 任务记录Controller
 * 
 * @author hpj
 * @date 2021-01-02
 */
@Api(value ="TaskRecordController")
@RestController
@RequestMapping("/ido/task_record")
public class TaskRecordController extends BaseController
{
    @Autowired
    private ITaskRecordService taskRecordService;

    /**
     * 查询任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:list')")
    @GetMapping("/list")
    @ApiOperation("查询任务记录列表")
    public TableDataInfo list(TaskRecord taskRecord)
    {
        startPage();
        List<TaskRecord> list = taskRecordService.selectTaskRecordList(taskRecord);
        return getDataTable(list);
    }

    /**
     * 导出任务记录列表
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:export')")
    @Log(title = "任务记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出任务记录列表")
    public AjaxResult export(TaskRecord taskRecord)
    {
        List<TaskRecord> list = taskRecordService.selectTaskRecordList(taskRecord);
        ExcelUtil<TaskRecord> util = new ExcelUtil<TaskRecord>(TaskRecord.class);
        return util.exportExcel(list, "task_record");
    }

    /**
     * 获取任务记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取任务记录详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(taskRecordService.selectTaskRecordById(id));
    }

    /**
     * 新增任务记录
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:add')")
    @Log(title = "任务记录", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增任务记录")
    public AjaxResult add(@RequestBody TaskRecord taskRecord)
    {
        return toAjax(taskRecordService.insertTaskRecord(taskRecord));
    }

    /**
     * 修改任务记录
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:edit')")
    @Log(title = "任务记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改任务记录")
    public AjaxResult edit(@RequestBody TaskRecord taskRecord)
    {
        return toAjax(taskRecordService.updateTaskRecord(taskRecord));
    }

    /**
     * 删除任务记录
     */
    @PreAuthorize("@ss.hasPermi('ido:task_record:remove')")
    @Log(title = "任务记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除任务记录")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(taskRecordService.deleteTaskRecordByIds(ids));
    }
}
